/*
 * Copyright (c) 2010 Network Security Lab (NSL), Department of Electrical
 *                    Engineering, University of Washington
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Author: He Wu mdzz@uw.edu
 */

/**
 * @file util.h
 * @brief Utility functions.
 */

#ifndef UTIL_H
#define UTIL_H

#include <linux/types.h>

/******************************************************************************/

/**
 * Set current node address according to the config file.
 */
int set_addr();

/**
 * @return Current node address.
 *
 * NOTICE must run set_addr() before calling this function.
 */
__u16 get_addr();

/**
 * @return 1 of current node is base node.
 *
 * NOTICE must run set_addr() before calling this function.
 */
int check_base();

/**
 * @brief Randomly skew the input with range of +-1/3 of its original value.
 * @param base Original value.
 * @return Skewed value.
 */
__u32 skew(__u32 base);

#endif
